pp108 : ondrop Property

ondrop Property


This is an optional property that contains the pointer to a function to be to be called when an item in the tree is dropped.

Syntax

XML

<TreeItem>
    <searchPath>sName</searchPath>
    <description>sDesc</description>
    <dragEnabled>bDrag</dragEnabled>
    <ondrop>fpFunction</ondrop>
        ...
        ...
        ...
</TreeItem>


Parameters

Parameter

Description

fpFunction

Pointer to a function that is to be called when an item in the tree is dropped.


Remarks


Once dragging is enabled on a tree item, the item can be dragged and dropped from one tree node to another node. To enable dragging, set the dragEnabled property to true.

To drag an item, select the item and hold the mouse on the item, and move the pointer to another tree node. Once the other node is reached, release the mouse click to drop the item. However, dragging the node will not update the corresponding data in the tree. It is the responsibility of the users to manually change the treeData.

If the return value of the function is set to 'false', then the item will not be dropped.

Example


The following example shows how the property is used.

<!-- Schema for tree. "dropHandler" is a function that will be called when item is dropped -->
<script type="cordys/xml" id="schema">
    <TreeSchema>
        <searchPath>//data/tuple/old/</searchPath>
        <Root>
            <description>Employees</description>
        </Root>
        <TreeItem id="EmployeesID">
            <searchPath>Employees</searchPath>
            <description>FirstName</description>
            <dragEnabled>true</dragEnabled>
            <ondrop>dropHandler</ondrop>
        </TreeItem>
    </TreeSchema>
</script>
//Function call
function dropHandler(droppedNode, newParent)
{
    <!-- Alert data of the dropped item -->
    application.notify("item dropped : " + cordys.getXML(droppedNode.data));
    <!-- Alert data of the new parent item under which it is dropped -->
    application.notify("new parent dropped : " + cordys.getXML(newParent.data));
     <!-- Return without dropping -->
    return false;
}

See Also


tree